<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>大屏图表适配解决方案</title>
    <meta name="keywords" content="大屏图表适配解决方案,ECharts,页面自适应,关中刀客在青岛,个人博客,前端技术博客">
    <meta name="description" content="多种模式适配各种比例的大屏，图表的配置项抽取各层级公用部分，定时刷新，页面时钟，城市定位，天气，颜色主题更换">
    <link rel="shortcut icon" href="/static/img/favicon.ico">
    <link rel="stylesheet" href="/static/assets/css/iconfont.css">
    <link rel="stylesheet" href="/static/css/common.css">
    <link rel="stylesheet" href="/static/css/index.css">
    <script src="/static/assets/js/jquery-3.3.1.min.js"></script>
</head>

<body id="investmentRisk">
<div id="container">
    <script src="../../static/js/common.js"></script>
    <header></header>
    <nav>
        <a href="map2d.html">进入地图</a>
        <a href="globe3d.html">进入3d地球</a>
        <a href="pb_studyPlan.html">学习计划进度</a>
    </nav>
    <main>
        <!--样式里的l,m,r,t,b分别代表左，中，右，上，下-->
        <div class="l">
            <div class="l-t">
                <div class="chart-wrap">
                    <h3>电白区2020年下半年各地区营销收入</h3>
                    <div class="chart" id="ec01_line_tiobe"></div>
                </div>
            </div>
            <div class="l-b">
                <div class="chart-wrap">
                    <h3>面积图</h3>
                    <div class="chart" id="ec02_area_accessSource"></div>
                </div>
            </div>
        </div>
        <div class="m">
            <div class="m-t">
                <div class="chart-wrap">
                    <h3>2020年下半年各线条总考核指标值</h3>
                    <div class="chart" id="ec03_barV_timeDistribute"></div>
                </div>
            </div>
            <div class="m-b">
                <div class="chart-wrap">
                    <h3>当电脑坏了的时候</h3>
                    <div class="chart" id="ec04_pie_computerBroken"></div>
                </div>
            </div>
        </div>

        <div class="r">
            <div class="r-t">
                <div class="chart-wrap">
                    <h3>2020年下半年各线条总考核指标值</h3>
                    <div class="chart" id="ec05_lineBar_timeDistribute"></div>
                </div>
            </div>
            <div class="r-b">
                <div class="chart-wrap">
                    <h3>当在网上找某首歌的时候</h3>
                    <div class="chart" id="ec06_pie_findSong"></div>
                </div>
            </div>
        </div>
    </main>
</div>
<aside></aside>
<script src="../../static/assets/js/echarts-4.2.0.min.js"></script>
<script src="../../static/js/chartsCom.js"></script>
<script >
    var dataStr =${d1}
         //var obj = JSON.parse(dataStr );
    var  datamonthy=${monthylist};
    var haillist=${haillist};



    var dataStr2 =${d2};
    var dataStr3 =${d3};
    var linelist=${linelistStr}





    let Index = {
        init() {
            this.charts = {};
            this.loadData();
            Public.chartsResize(this.charts);
            Public.chartsReDraw(this.charts, null, [
                'ec01_line_tiobe', 'ec06_pie_findSong'
            ], [
                'ec03_barV_timeDistribute', 'ec05_lineBar_timeDistribute', 'ec06_pie_findSong'
            ])
        },
        loadData() {
            this.ec01_line_tiobe();//
            this.ec02_area_accessSource();//
            this.ec03_barV_timeDistribute();//
            this.ec04_pie_computerBroken();//
            this.ec05_lineBar_timeDistribute();//
            this.ec06_pie_findSong();//
        },
        ec01_line_tiobe() {
            let chart = echarts.init($("#ec01_line_tiobe")[0]); //初始化图表，注意命名的规范合理
            this.charts.ec01_line_tiobe = chart; //放入charts对象方便后面的刷新缩放以及其他操作
            chart.setOption(opt_line); // 设置这个类型（折线图）图表的共性
            chart.setOption({
                xAxis: { // 本图表option的个性
                    nameLocation: 'end',
                    inverse: "auto",
                    data: datamonthy
                },
                yAxis: { // 本图表option的个性
                    name: '排名',
                    nameLocation: 'start',
                    max: 50000,
                    inverse: "auto"
                },
                dataZoom: { // 本图表option的个性
                    type: 'inside',
                    orient: 'horizontal'
                },


                series:dataStr.map(item => {
                    return $.extend(true, {}, seri_line,// 折线图图表series的共性
                        { // 本图表series的个性
                            symbol:'circle',
                            smooth: false,
                            showSymbol: false,
                        }, item)
                })
            })
        },
        ec02_area_accessSource() {
            let chart = echarts.init($("#ec02_area_accessSource")[0]);
            this.charts.ec02_area_accessSource = chart;
            chart.setOption(opt_line);
            chart.setOption({
                xAxis: {
                    data: datamonthy,
                    nameLocation: 'start',
                },
                yAxis: {
                    name: '数量/次',
                    nameLocation: 'start',
                },
                series: dataStr2.map(item => {
                    return $.extend(true, {}, seri_area, {
                        symbol: 'circle',
                    }, item)
                })
            });
        },
        ec03_barV_timeDistribute() {
            let chart = echarts.init($("#ec03_barV_timeDistribute")[0]);
            this.charts.ec03_barV_timeDistribute = chart;
            chart.setOption(opt_bar_v);
            chart.setOption({
                xAxis: {
                    data: datamonthy
                },
                yAxis: {
                    name: '当月收入/万元',
                },
                series:dataStr2.map(item => {
                    return $.extend(true, {}, seri_bar_v, item, {stack: '总时间'})
                })
            })
        },
        ec04_pie_computerBroken() {
            let chart = echarts.init($("#ec04_pie_computerBroken")[0]);
            this.charts.ec04_pie_computerBroken = chart;
            chart.setOption(opt_pie);
            chart.setOption({
                roseType: 'radius',
                series: [
                    {
                        name: "电脑坏了",
                        data: [{
                            value: 72,
                            name: '重启'
                        },{
                            value: 3,
                            name: '找人帮忙'
                        }, {
                            value: 10,
                            name: '放弃使用'
                        }, {
                            value: 15,
                            name: '想法修复'
                        } ]
                    },
                ].map(item => {
                    return $.extend(true, {}, seri_circle, item)
                })
            })
        },
        ec05_lineBar_timeDistribute() {
            let chart = echarts.init($("#ec05_lineBar_timeDistribute")[0]);
            this.charts.ec05_lineBar_timeDistribute = chart;
            chart.setOption(opt_line);
            chart.setOption({
                legend: {
                    data:linelist
                },
                tooltip: {
                    formatter: function (param) {
                        return param.map(item => {
                            if (item.seriesName === '补位') {
                                return ''
                            } else {
                               return "<font style='font-size: 10px'>"+item.seriesName+":"+item.value+"</font>"+"<br>"
                            }
                        }).join("").replace(',', '')

                    }
                },
                xAxis: {
                    boundaryGap: true,
                    data: datamonthy
                },
                yAxis: {
                    name: '时间/小时',
                },
                series: [
                   haillist, {
                        name: '补位',
                        silent: true,
                        itemStyle: {
                            color: c_bg_bar,
                        },
                        barGap: '-100%',
                        data: new Array(6).fill(1600)
                    }
                ].map(item => {
                    return $.extend(true, {}, seri_bar_v, item)
                }).concat(dataStr3.map(item => {
                    console.log(item);
                    return $.extend(true, {}, seri_line, {
                        symbol: 'emptyCircle'
                    }, item)
                }))
            })
        },
        ec06_pie_findSong() {
            let chart = echarts.init($("#ec06_pie_findSong")[0]);
            this.charts.ec06_pie_findSong = chart;
            chart.setOption(opt_pie);
            chart.setOption({
                roseType: 'radius',
                visualMap: {
                    show: false,
                    min: 0,
                    max: 100,
                    inRange: {
                        colorLightness: [0.3, 1.2]
                    }
                },

                series: [
                    {
                        name: "视频网站找歌的结果",
                        itemStyle: {
                            normal: {
                                color: colors[0],
                                shadowBlur: 100 * scale,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        },
                        data: [{
                            value: 40,
                            name: '手机拍的现场版'
                        }, {
                            value: 30,
                            name: '翻唱'
                        }, {
                            value: 18,
                            name: '尤克里里的演奏'
                        }, {
                            value: 10,
                            name: '该视频已被删除'
                        }, {
                            value: 2,
                            name: '找到了'
                        }].sort(function (a, b) {
                            return a.value - b.value;
                        }),
                    },
                ].map(item => {
                    return $.extend(true, {}, seri_pie, item)
                })
            })
        }
    };
    Index.init();



</script>
</body>
</html>

<!--/usr/local/apache-tomcat-9.0.16/webapps/ROOT/projects/bigScreenCharts-->





